﻿	      <?php include("conn.php");
             mysql_query('SET NAMES UTF8'); 

	  

class MyPrizeBean
{
	
	public $content;
	function __construct($content)
	{
	
		$this->content      = $content;
		
	}
}


$arrType=array('media/amr');
$max_size='5000000000';      // 最大文件限制（单位：byte）
$upfile='uploads'; //图片目录路径
$file=$_FILES['upfile'];
  
   if($_SERVER['REQUEST_METHOD']=='POST'){ //判断提交方式是否为POST
   
   
  if($file['size']>$max_size){  //判断文件大小是否大于500000字节
   
   } 

  if(!file_exists($upfile)){  // 判断存放文件目录是否存在
   mkdir($upfile,0777,true);
   } 
      $imageSize=getimagesize($file['tmp_name']);
   $img=$imageSize[0].'*'.$imageSize[1];
   $fname="1.amr";
   $ftype=explode('.',$fname);
   $picName=$upfile."/cloudy".date("Ymdhis").$fname;
   
  
   if(!move_uploaded_file($file['tmp_name'],$picName)){  
   
    }
   else{
    }
      }

   $imgd="http://120.24.0.10/zhiqin/api/".$picName;
$date=date("Y-m-d h:i:s");
$r2=mysql_query("select max(shu) AS total from message");
		  $rr2=mysql_fetch_array($r2);
		  $shu=$rr2[total]+1;
$srat=mysql_query("INSERT INTO message(content,userid,addtime,shu,times) VALUES ('$imgd','$_REQUEST[userid]','$date','$shu','$_REQUEST[times]')");

	$count=mysql_query("select count(*) from message");

//收藏的宝贝 计数
$rs=mysql_fetch_array($count);
$t1=$rs[0];


$page=$t1-10;


	$rert30=mysql_query("select *from message  order by messageid  limit $page,10");
	
	$prize = array();
	$content="";

while($rowf=mysql_fetch_array($rert30))
{



	  
 
$rert32=mysql_query("select *from user where  userid ='".$rowf[userid]."'");
		  $rowf1=mysql_fetch_array($rert32);
		 if($rowf[userid]==$_REQUEST[userid])
		  {
		     if(strpos($rowf[content],".amr") > 0){
			 
			                     $content.="<li class=my url='".$rowf[shu]."'  onClick=play('".$rowf[content]."',this)><div class=cnt><div class=cnt_border  ><img src='../image/yy.png' height='20' width='20' class='yy'/>   <span class='time'>".$rowf[times]."s</span></div><span class=bg></span><span class=bor></span></div><div class=head_image><img src='http://120.24.0.10/zhiqin/api/".$rowf1[images]."'/></div></li>";
			                   }
							   
							   else if(strpos($rowf[content],".png") > 0 and strpos($rowf[content],".png") < 2)
								{			   
		 $content.="<li class=my><div class=cnt><div class=cnt_border   >".$rowf[content]."</div><span class=bg></span><span class=bor></span></div><div class=head_image><img src='http://120.24.0.10/zhiqin/api/".$rowf1[images]."'/></div></li>";
								}
								
							   else
							   {
							   
		 $content.="<li class=my><div class=cnt><div class=cnt_border   >".$rowf[content]."</div><span class=bg></span><span class=bor></span></div><div class=head_image><img src='http://120.24.0.10/zhiqin/api/".$rowf1[images]."'/></div></li>";
		                       }
		 }
		 else
		  {
		      
			  if(strpos($rowf[content],".amr") > 0){
			   $content.="<li class='you' url='".$rowf[shu]."'  onClick=play('".$rowf[content]."',this)><div class='head_image'><img src='http://120.24.0.10/zhiqin/api/".$rowf1[images]."'/></div><div class='cnt'><div class='cnt_border'><div class='cnt_content' ><img class='yy' src='../image/yy.png' height='20' width='20'/></div><span class='time'>".$rowf[times]."s</span></div><span class='bg'></span><span class='bor'></span></div></li>";
			  }
				  else if(strpos($rowf[content],".png") > 0 and strpos($rowf[content],".png") < 2)
								{	
								 $content.="<li class='you'><div class='head_image'><img src='http://120.24.0.10/zhiqin/api/".$rowf1[images]."'/></div><div class='cnt'><div class='cnt_border'><div class='cnt_content' >".$rowf[content]."<div></div></div></div><span class='bg'></span><span class='bor'></span></div></li>";
								}
							
			  else
			  {
		 $content.="<li class='you'><div class='head_image'><img src='http://120.24.0.10/zhiqin/api/".$rowf1[images]."'/></div><div class='cnt'><div class='cnt_border'><div class='cnt_content'>".$rowf[content]."<div></div></div></div><span class='bg'></span><span class='bor'></span></div></li>";
		     }
		 }
	}	
	
	$prize[] = new MyPrizeBean($content);
		
	

echo json_encode($prize);


?>